import request from "@/lib/utils/request";
import { Dept, DeptTree } from "./dept.d";
import { Response, PaginationType } from "../common";

export const getDeptListApi = (params: PaginationType): Response<Dept[]> => {
  return request.get("/system/dept/list", { params });
};

export const addDeptApi = (data: Dept): Response<null> => {
  return request.post("/system/dept", data);
};

export const updateDeptApi = (data: Dept): Response<null> => {
  return request.put("/system/dept", data);
};

export const deleteDeptApi = (deptId: number): Response<null> => {
  return request.delete(`/system/dept/${deptId}`);
};

export const getDeptApi = (deptId: string): Response<Dept> => {
  return request.get(`/system/dept/${deptId}`);
};

export const getDeptTreeApi = (): Response<DeptTree[]> => {
  return request.get(`system/user/deptTree`);
};
